package com.corticon.dialogs.model;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;


/**
 * RiskRating entity.
 * 
 * @author Yanglifan
 */
@Entity
@Table(name = "riskrating")
public class RiskRating extends AuditableEntity implements Serializable {

    private Long riskRatingId;
    private String id;
    private String rating;
    private Set<LoanProduct> loanProducts = new HashSet<LoanProduct>();
    private Set<Score> scores = new HashSet<Score>();
    private Set<Quote> quotes = new HashSet<Quote>();

    public RiskRating() {
    }

    @Id
    @SequenceGenerator(name = "riskrating_id_seq",
                       sequenceName = "riskrating_id_seq",
                       allocationSize = 1, initialValue = 1) // Set allocationSize and initialValue
                                                             // to let sequence increment following DB.
    @GeneratedValue(strategy = GenerationType.AUTO, generator = "riskrating_id_seq")
    @Column(name = "riskrating_id",  nullable = false, columnDefinition = "integer")
    public Long getRiskRatingId() {
        return this.riskRatingId;
    }

    public void setRiskRatingId(Long riskRatingId) {
        this.riskRatingId = riskRatingId;
    }

    @Column(name = "id", length = 256)
    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Column(name = "rating", length = 256)
    public String getRating() {
        return this.rating;
    }

    public void setRating(String rating) {
        this.rating = rating;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "riskRating")
    public Set<LoanProduct> getLoanProducts() {
        return this.loanProducts;
    }

    public void setLoanProducts(Set<LoanProduct> loanProducts) {
        this.loanProducts = loanProducts;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "riskRating")
    public Set<Score> getScores() {
        return this.scores;
    }

    public void setScores(Set<Score> scores) {
        this.scores = scores;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "riskRating")
    public Set<Quote> getQuotes() {
        return this.quotes;
    }

    public void setQuotes(Set<Quote> quotes) {
        this.quotes = quotes;
    }
}